package com.yunbiao.ybbusstopplate.base.alive

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import com.blankj.utilcode.util.AppUtils
import com.blankj.utilcode.util.LogUtils
import com.yunbiao.ybbusstopplate.base.APP
import com.yunbiao.ybbusstopplate.base.ContentValue

class BootRestartReceiver :BroadcastReceiver(){

    private val ACTION_BOOT_COMPLETED="android.intent.action.BOOT_COMPLETED"
    override fun onReceive(p0: Context?, p1: Intent?) {
//        val action = p1!!.action
        if (p0!=null&&(p1!=null&&ACTION_BOOT_COMPLETED.equals(p1.action))){
            AppUtils.launchApp(APP.getAppContext()?.packageName)
            //保活程序
            if (ContentValue.startSelf){
                Log.d("KeepAliveService", "onReceive: -------------------")
                LogUtils.dTag("BootRestartReceiver---->","start service")
                KeepAliveService.startKeepAliveService(p0)
            }
        }
    }
}